package middleware

import (
	"github.com/gin-gonic/gin"
	"openapi.itspire.cn/common/throw"
)

func Recovery() gin.HandlerFunc {
	return func(c *gin.Context) {
		defer func() {
			if err := recover(); err != nil {
				throw.ServerError(c, err.(string))
			}
		}()

		c.Next()
	}
}
